import request from '@/utils/request'

// 用户文章列表
export const getArticles = params => {
  return request({
    url: '/v1_0/articles',
    method: 'get',
    params
  })
}

/**
  * 获取频道的文章详情列表
  */
export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: '/v1_0/articles/' + articleId
  })
}
/**
 * 收藏文章
 */
export const addcollections = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}
/**
 * 取消收藏
 */
export const deletecollections = (target) => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`
  })
}
/**
 * 点赞文章
 */
export const addattitude = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}
/**
 * 点赞文章
 */
export const deleteattitude = target => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/:target',
    data: {
      target
    }
  })
}
/**
 * 对评论或评论回复点赞
 */
export function addCommentLike (commentId) {
  return request({
    method: 'POST',
    url: '/v1_0/comment/likings',
    data: {
      target: commentId
    }
  })
}

/**
 * 取消对评论或评论回复点赞
 */
export function deleteCommentLike (commentId) {
  return request({
    method: 'DELETE',
    url: `/v1_0/comment/likings/${commentId}`
  })
}
/**
 * 添加评论或评论回复
 */
export function addComment (data) {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data
  })
}
